FUNCTION_BLOCK LCB_Speed_vToSpeed_s 
TITLE = 'LCB_Speed_vToSpeed_s'

// This FB converts a 16-bit speed signal into a 32-bit speed signal.
//
// Versionshistory:
// 1.0 Ersterstellung R.Enders   

VERSION : '1.0'
AUTHOR  : 'Lenze'
FAMILY  : 'LCB'
NAME : 'SvToSs' // ( 8 Zeichen max.)
KNOW_HOW_PROTECT

VAR_INPUT
    iIn_v:INT;
END_VAR

VAR_OUTPUT
    diOut_s    :DINT;
END_VAR
VAR
    tmp1:INT;
    tmp2:DWORD; 
 END_VAR

BEGIN
// diOut_s := SHL(INT_TO_DINT(LIMIT(-32767, iIn_v, 32767)), 12);

// diOut_s := DWORD_TO_DINT(SHL( IN:= INT_TO_DWORD(LIMIT(MN:=-32767, IN:= iIn_v, MX:=32767)),N:=12));

tmp1:= LIMIT (MN:= -32767,IN:=iIn_v,MX:= 32767);
tmp2:= INT_TO_DWORD (tmp1);
tmp2:= SHL ( IN:=tmp2,N:=12);
diOut_s:= DWORD_TO_DINT (tmp2);


END_FUNCTION_BLOCK

